﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TYARNTYP 
    {
        #region ==YARNTYP===========
        public static readonly DependencyProperty YARNTYPProperty = DependencyProperty.Register("YARNTYP",
            typeof(string), typeof(TYARNTYP),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnYARNTYPChanged));
        public string YARNTYP
        {
            get
            {
                return (string)GetValue(YARNTYPProperty);
            }
            set
            {
                SetValue(YARNTYPProperty, value);
            }
        }
        private static void OnYARNTYPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TYARNTYP;
            if (src != null)
            {
                src.YARNTYP = (string)e.NewValue;
            }
        }
        #endregion
        public TYARNTYP()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVKPOS();
            this.DataContext = MV;
            InitializeComponent(); 
            
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                YARNTYP = "";
                return;
            }
            YARNTYP = dwMaster["YARNTYP"].ToString();
        }
    
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
            SResult = ((VVKPOS)MV).QueryVKPOS(dwData, -2);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                row["YARNTYP"] = Helpers.Helper.Convert8859P1ToGB2312(row["YARNTYP"].ToString());
            }
            MergeData(SResult);
            vwMaster.View.MoveCurrentTo(-1);
        }
       
    }
 
}
